/*
 * LocalMonitor.h  0.4.0 / Nov 14, 2010
 *
 * Copyright (c) 2010 - 2011, cute4j.com and contributors.
 *
 * This software is licensed under the LGPL version 2.1 license.
 * A copy of this license is included in the file LICENSE-LGPL.txt.
 */
#ifndef LOCALMONITOR_H
#define LOCALMONITOR_H

#include "Cute4jCommon.h"

// LocalMonitor Class. ---------------------------------------------------------

/*!
 * \brief Local Monitor.
 *
 * \author Slobodan Vrkacevic
 * \version 0.4.0
 */
class CUTE4J_EXPORT LocalMonitor
{
public:
  LocalMonitor(JNIEnv *env, jobject obj, jfieldID lockField = 0);
  virtual ~LocalMonitor();
private:
  LocalMonitor(const LocalMonitor &);
public:
  bool enter();
  bool exit();
public:
  inline bool isEntered() const;
protected:
  JNIEnv *m_env;
  jobject m_obj;
  bool m_entered;
};

// LocalMonitor :: Inline Member Functions. ------------------------------------

/*!
 * \brief Returns \c true if the monitor is enered.
 *
 * \return \c true if the monitor is enered
 */
inline bool LocalMonitor::isEntered() const
{
  return m_entered;
}

#endif // LOCALMONITOR_H
